{% extends 'base_backend.html' %}
{% load static %}
{% load my_filter %}

{% block header_tail %}
    <link rel="stylesheet" href="{% static 'zhongbao/zhongbao_admin/css/style.css' %}">
    <link rel="stylesheet" href="{% static 'zhongbao/zhongbao_admin/css/iconfont.css' %}">
    <link rel="stylesheet" href="{% static 'plugins/datatables/dataTables.bootstrap.css' %}">
    <link rel="stylesheet" href="{% static 'public/ComboSelect/css/combo.select.css' %}">
    <link rel="stylesheet" href="{% static 'zhongbao/config/css/main.css' %}">

    <script src="{% static 'plugins\jQuery\jquery-2.2.3.min.js' %}"></script>

    <script src="{% static 'plugins/vue1/vue.js' %}"></script>

    <style>
        .login-banner {
            width: 100%;
            background: url("{% static 'public/img/banner2.jpg' %}") center bottom/cover no-repeat;
        }
    </style>
{% endblock header_tail %}

{% block section_content %}
    <div style="margin-right: -15px; margin-left: -15px; margin-bottom: -20px;">
        <div class="col-lg-2 col-xs-4">
            <div class="small-box bg-aqua">
                <div class="inner">
                    <p>全部</p>
                    <h3 id="accept">{{ total }}</h3>
                </div>
                <div class="icon" style="padding-top: 15px;">
                    <i class="fa fa-coffee"></i>
                </div>
                <!--<a href="{% url 'task:accept' %}"  class="small-box-footer">-->
                {% if is_agent  %}
                    <a href="{% url 'task:project_detail_agent' model_DOM_id %}?pid={{ pid }}"  class="small-box-footer">
                {% endif %}
                {% if not is_agent%}
                    <a href="{% url 'task:project_detail' model_DOM_id %}?pid={{ pid }}"  class="small-box-footer">
                {% endif %}
                    详情&nbsp;
                    <i class="fa fa-arrow-circle-right"></i>
                </a>
            </div>
        </div>
        <div class="col-lg-2 col-xs-4">
            <div class="small-box bg-green">
                <div class="inner">
                    <p>处理中</p>
                    <h3 id="status2">{{ counts.1 }}<sup style="font-size: 20px"></sup></h3>
                </div>
                <div class="icon" style="padding-top: 15px;">
                    <i class="fa fa-sitemap"></i>
                </div>
                {% if is_agent  %}
                    <a href="{% url 'task:project_detail_agent' model_DOM_id %}?pid={{ pid }}&status=2" class="small-box-footer">
                {% endif %}
                {% if not is_agent%}
                    <a href="{% url 'task:project_detail' model_DOM_id %}?pid={{ pid }}&status=2" class="small-box-footer">
                {% endif %}
                    详情&nbsp;
                    <i class="fa fa-arrow-circle-right"></i>
                </a>
            </div>
        </div>
        <div class="col-lg-2 col-xs-4">
            <div class="small-box bg-yellow">
                <div class="inner">
                    <p>待审核</p>
                    <h3 id="status3">{{ counts.2 }}</h3>
                </div>
                <div class="icon" style="padding-top: 15px;">
                    <i class="fa fa-list"></i>
                </div>
                {% if is_agent %}
                    <a href="{% url 'task:project_detail_agent' model_DOM_id %}?pid={{ pid }}&status=3" class="small-box-footer">
                {% endif %}
                {% if not is_agent %}
                    <a href="{% url 'task:project_detail' model_DOM_id %}?pid={{ pid }}&status=3" class="small-box-footer">
                {% endif %}
                    详情&nbsp;
                    <i class="fa fa-arrow-circle-right"></i>
                </a>
            </div>
        </div>
        <div class="col-lg-2 col-xs-4">
            <div class="small-box bg-red">
                <div class="inner">
                    <p>已合格</p>
                    <h3 id="status4">{{ counts.3 }}</h3>
                </div>
                <div class="icon" style="padding-top: 15px;">
                    <i class="fa fa-bell"></i>
                </div>
                {% if is_agent  %}
                    <a href="{% url 'task:project_detail_agent' model_DOM_id %}?pid={{ pid }}&status=4" class="small-box-footer">
                {% endif %}
                {% if not is_agent%}
                    <a href="{% url 'task:project_detail' model_DOM_id %}?pid={{ pid }}&status=4" class="small-box-footer">
                {% endif %}
                    详情&nbsp;
                    <i class="fa fa-arrow-circle-right"></i>
                </a>
            </div>
        </div>
        <div class="col-lg-2 col-xs-4">
            <div class="small-box bg-purple-gradient">
                <div class="inner">
                    <p>未合格</p>
                    <h3 id="status5">{{ counts.4 }}</h3>
                </div>
                <div class="icon" style="padding-top: 15px;">
                    <i class="fa fa-book"></i>
                </div>
                {% if is_agent %}
                    <a href="{% url 'task:project_detail_agent' model_DOM_id %}?pid={{ pid }}&status=5" class="small-box-footer">
                {% endif %}
                {% if not is_agent%}
                    <a href="{% url 'task:project_detail' model_DOM_id %}?pid={{ pid }}&status=5" class="small-box-footer">
                {% endif %}
                    详情&nbsp;
                    <i class="fa fa-arrow-circle-right"></i>
                </a>
            </div>
        </div>
        <div class="col-lg-2 col-xs-4">
            <div class="small-box bg-gray-active">
                <div class="inner">
                    <p style="color: white;">已回收</p>
                    <h3 id="status0" style="color: white;">{{ counts.5 }}</h3>
                </div>
                <div class="icon" style="padding-top: 15px;">
                    <i class="fa fa-archive"></i>
                </div>
                {% if is_agent  %}
                    <a href="{% url 'task:project_detail_agent' model_DOM_id %}?pid={{ pid }}&status=0"  class="small-box-footer">
                {% endif %}
                {% if not is_agent%}
                    <a href="{% url 'task:project_detail' model_DOM_id %}?pid={{ pid }}&status=0"  class="small-box-footer">
                {% endif %}
                    详情&nbsp;
                    <i class="fa fa-arrow-circle-right"></i>
                </a>
            </div>
        </div>
    </div>
    <div>
        <div class="box-header with-border">
            <h3 class="box-title">{{ model_verbose_name }}</h3>
        </div>

        <!-- form start -->
        <div class="box box-primary">
            <div class="box-header with-border" style="border-color: #1b6d85">
        <!-- 展示搜索出来的任务 -->
            <div id="main">
                <div id="showMessage" v-show="message"> [[ message ]]</div>
                <div class="box-body" v-show="showMain">
                    <form id="model_form" role="form"
                          method="post">{% csrf_token %}
                        <div class="group">
                             {% if status == '4' %}
                                 {% if user.is_superuser %}
                                    <a style="margin-right:20px;" type="button" class="btn btn-primary btn-xs" onclick="_adopt()">通过（批量）</a>
                                 {% endif %}
                             {% endif %}
                            <a style="margin-right:20px;" type="button" class="btn btn-primary btn-xs">当前窗口为" 项目管理 > 详情 "窗口</a>
                            <a style="margin-right:20px;" type="button" class="btn btn-info btn-xs" onclick="allUnqualified('{{ pid }}')">以合格任务全部不合格</a>
                            <a style="margin-right:20px;" type="button" class="btn btn-warning btn-xs" onclick="allUnqualified1('{{ pid }}')">待审核任务全部不合格</a>
                            <span >共<b>{{ total }}</b>个</span>
                            <table id="task_each_table" border="1" class="table table-bordered table-hover table-striped">
                                <thead>
                                <tr>
                                    {% if status == '4' %}
                                    <th class="action-checkbox">
                                        <input type="checkbox" name="th_checkbox" onclick="checkAll(this)">
                                    </th>
                                    {% endif %}
                                    <th v-for="head in tableData.headers">
                                        <span style="float: left">
                                            [[ head.name ]]
                                        </span>
                                        {% if field.rank %}
                                            <a href="?[[ head.rank ]]=[[ head.rank_tag ]][[ page_args ]]"
                                               style="float: right">
                                                {% if field.rank_tag == 0 %}
                                                    <i class="fa fa-fw fa-sort"></i>
                                                {% elif field.rank_tag == 1 %}
                                                    <i class="fa fa-fw fa-sort-numeric-asc"></i>
                                                {% elif field.rank_tag == -1 %}
                                                    <i class="fa fa-fw fa-sort-numeric-desc"></i>
                                                {% endif %}
                                            </a>
                                        {% endif %}
                                    </th>
                                    <th>
                                        <span style="float: left">
                                            采集数量
                                        </span>
                                    </th>
                                    <th>
                                        <span style="float: left">
                                            代码正则
                                        </span>
                                    </th>
                                    <th>
                                        <span style="float: left">
                                            操作
                                        </span>
                                    </th>
                                </tr>
                                </thead>
                                <tbody>
                                    <template v-for="task in tableData.tasks">
                                        <!--<tr v-if="task.allocation_flag">-->
                                        <tr>
                                            {% if status == '4' %}
                                                <td class="action-checkbox">
                                                    <input type="checkbox" name="td_checkbox" value="[[ task.id ]]" onclick="checkOne(this)">
                                                </td>
                                            {% endif %}
                                            <template v-for="head in tableData.headers">
                                                <template v-if="head.key == 'submit_flag' || head.key == 'deadline_flag' || head.key == 'allocation_flag' || head.key == 'receive_flag' || head.key == 'finish_flag' || head.key == 'ctime' || head.key == 'status' || head.key == 'warehousing_flag'">
                                                    <td v-if="head.key == 'status'">[[ parseStatus(task[head.key]) ]]</td>
                                                    <td v-else>[[ parseTime(task[head.key]) ]]</td>
                                                </template>
                                                <template v-else>
                                                    <td v-if="head.key == 'site_url'"><a href="[[ task[head.key] ]]" target="_Blank" title="[[ task[head.key] ]]">[[ truncatechars(task[head.key], 30) ]]</a></td>
                                                    <td v-else title="[[ task[head.key] ]]">[[ truncatechars(task[head.key], 10) ]]</td>
                                                </template>
                                            </template>
                                            <td>
                                                <a class="btn-link channels-tr" style="cursor: pointer" onclick="getGatherCount([[ task.id ]])">查看采集数量</a>
                                            </td>
                                            <td>
                                                <a class="btn-link channels-tr" style="cursor: pointer" onclick="getRegexp([[ task.id ]])">查看</a>
                                            </td>
                                            <td class="btn-group">
                                                {% if model_DOM_id == 'manage' %}
                                                    {% if user.is_superuser %}
                                                    <button v-if="task.status == 3 || task.status == 6" type="button" value="[[ task.id ]]" class="btn btn-info btn-xs" onclick="retrieveOneTask([[task.id]])">回收</button>
{#                                                        <button v-if="task.status == 5" type="button" value="[[ task.id ]]" class="btn btn-info btn-xs" onclick="adoptone([[task.id]])">通过</button>#}
                                                     {% endif %}
                                                    <button v-if="task.unqualified_flag > 0" type="button" value="[[ task.id ]]" class="btn btn-info btn-xs" onclick="auditRecord([[ task.id ]])">审核记录</button>
                                                    <button v-if="task.status == 3 || task.status == 6" type="button" value="[[ task.id ]]" class="btn btn-info btn-xs" onclick="Assignment([[task.id]],[[task.agency]])">重新分派</button>
                                                    <button v-if="task.status == 2" type="button" value="[[ task.id ]]" class="btn btn-info btn-xs" onclick="allocateOneTask([[task.id]], [[task.agency]])">分配</button>
                                                {% endif %}
                                                <button type="button" value="[[ task.id ]]" class="btn btn-info btn-xs" onclick="detailOneTask([[task.id]])">详情</button>
                                            </td>
                                        </tr>
                                    </template>
                                </tbody>
                            </table>
                            <p class="" id="paginator">
                                <a class="btn btn-default btn-xs" v-if="paginator.current > 1" onclick="toPage('first',paginator.limit)">首页</a>
                                <a class="btn btn-default btn-xs" v-else disabled="true">首页</a>
                                <a class="btn btn-default btn-xs" v-if="paginator.current > 1" onclick="toPage('prev',paginator.limit)">上一页</a>
                                Page [[ paginator.current ]] of [[ paginator.last ]]

                                <a class="btn btn-default btn-xs" v-if="paginator.current < paginator.last" onclick="toPage('next',paginator.limit)">下一页</a>
                                <a class="btn btn-default btn-xs" v-if="paginator.current < paginator.last" onclick="toPage('last',paginator.limit)">尾页</a>
                                <a class="btn btn-default btn-xs" v-else disabled="true">尾页</a>
                                <input type="text" id="page-judge" style="width: 30px;height:20px; margin-left: 20px" onkeyup="toPage('judge', paginator.limit)">
                                <a class="btn btn-default btn-xs"  onclick="toPage('judge', paginator.limit)">跳页</a>
                            </p>
                        </div>
                        {% if model_DOM_id == 'accept' %}
                            <p class="btn btn-primary" onclick="accept_project(getUrlParam('pid'))" style="margin: 15px 5px ">领取项目</p>
                        {% endif %}
                        <!-- /.box-footer -->
                        <div class="box-footer">
                            <button class="btn btn-primary no-display" id="submit_button">确认</button>
                            <button type="button" class="btn btn-primary" id="save_submit" name="_save"
                                    style="display: none">sure
                            </button>
                        </div>
                    </form>
                </div>
                <!--审核记录-start-->
                <div class="modal fade" id="auditRecord" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" style="overflow: hidden; ">
                    <div class="modal-dialog" role="document">
                        <div class="modal-content">
                            <div class="modal-header" style="background-color: #307095;font-weight: bold;">
                                <label>任务审核记录</label>
                            </div>
                            <div class="modal-body" style="overflow-y: scroll; max-height: 500px;">
                                <table id="user_each_table" border="1" class="table table-bordered table-hover table-striped">
                                    <thead>
                                        <tr>
                                            <th class="action-checkbox">
                                                <span style="float: left">
                                                    审核时间
                                                </span>
                                            </th>
                                            <th>
                                                <span style="float: left">
                                                    变更前
                                                </span>
                                            </th>
                                            <th>
                                                <span style="float: left">
                                                    变更后
                                                </span>
                                            </th>
                                            <th style="width: 350px;">
                                                <span style="float: left">
                                                    不合格原因
                                                </span>
                                            </th>
                                            <th>
                                                <span style="float: left">
                                                    审核人员
                                                </span>
                                            </th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <tr v-if="auditRecord == '' ">
                                                <td>暂无记录</td><td></td><td></td><td></td><td></td>
                                        </tr>
                                        <template v-for="record in auditRecord">
                                            <tr>
                                                <td>
                                                    <span>[[ parseTime(record.changed_flag) ]]</span>
                                                </td>
                                                <td>
                                                    <span>[[ record.changed_before ]]</span>
                                                </td>
                                                <td>
                                                    <span>[[ record.changed_after ]]</span>
                                                </td>
                                                <td>
                                                    <span>[[ record.unfeedback ]]</span>
                                                </td>
                                                <td>
                                                    <span>[[ record.auditor ]]</span>
                                                </td>
                                            </tr>
                                        </template>
                                    </tbody>
                                </table>
                            </div>
                            <div class="modal-footer">
                                <button type="button" class="btn btn-default" data-dismiss="modal">确认</button>
                            </div>
                        </div>
                    </div>
                </div>
                <!--审核记录-end-->
            </div>
        </div>
    </div>

     <!--用户列表，任务分配-->
<!--    <div class="modal fade" id="userList" tabindex="-1" role="dialog"-->
<!--         aria-labelledby="myModalLabel" style="overflow: hidden; ">-->
<!--        <div class="modal-dialog" role="document">-->
<!--            <div class="modal-content">-->
<!--                <div class="modal-header" style="background-color: #307095;font-weight: bold;">-->
<!--                    <label>请选择要分配给谁：</label>-->
<!--                </div>-->
<!--                <div class="modal-body" style="overflow-y: scroll; max-height: 500px;">-->
<!--                    <table id="user_each_table" border="1" class="table table-bordered table-hover table-striped">-->
<!--                        <thead>-->
<!--                            <tr>-->
<!--                                <th class="action-checkbox">-->
<!--                                </th>-->
<!--                                <th>-->
<!--                                    <span style="float: left">-->
<!--                                        用户名-->
<!--                                    </span>-->
<!--                                </th>-->
<!--                            </tr>-->
<!--                        </thead>-->
<!--                        <tbody id ='aaa'>-->
<!--{#                            {% for user in configUsers %}#}-->
<!--{#                                <tr>#}-->
<!--{#                                    <td class="action-checkbox">#}-->
<!--{#                                        <input type="checkbox" name="utd_checkbox" value="{{ user.user.id }}" onclick="_checkOne(this)">#}-->
<!--{#                                    </td>#}-->
<!--{#                                    <td>{{ user.user.username }}</td>#}-->
<!--{#                                </tr>#}-->
<!--{#                            {% endfor %}#}-->
<!--                        </tbody>-->
<!--                    </table>-->
<!--                </div>-->
<!--                <div class="modal-footer">-->
<!--                    <button type="button" id="confirm_close" class="btn btn-default"-->
<!--                            data-dismiss="modal" onclick="confirmClose()">确认-->
<!--                    </button>-->
<!--                    <button type="button" id="cancel_close" class="btn btn-default"-->
<!--                            data-dismiss="modal" onclick="cancelClose()">取消-->
<!--                    </button>-->
<!--                </div>-->
<!--            </div>-->
<!--        </div>-->
<!--    </div>-->

     <!--用户列表，任务分配-->
    <div class="modal fade" id="userListAssignment" tabindex="-1" role="dialog"
         aria-labelledby="myModalLabel" style="overflow: hidden; ">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header" style="background-color: #307095;font-weight: bold;">
                    <label>请选择要分配给谁：</label>
                </div>
                <div class="modal-body" style="overflow-y: scroll; max-height: 500px;">
                    <table id="user_each_table" border="1" class="table table-bordered table-hover table-striped">
                        <thead>
                            <tr>
                                <th class="action-checkbox">

                                </th>
                                <th>
                                    <span style="float: left">
                                        用户名
                                    </span>
                                </th>
                            </tr>
                        </thead>
                        <tbody id ='bbb'>
{#                            {% for user in configUsers %}#}
{#                                <tr>#}
{#                                    <td class="action-checkbox">#}
{#                                        <input type="checkbox" name="utd_checkbox" value="{{ user.user.id }}" onclick="_checkOne(this)">#}
{#                                    </td>#}
{#                                    <td>{{ user.user.username }}</td>#}
{#                                </tr>#}
{#                            {% endfor %}#}
                        </tbody>
                    </table>
                </div>
                <div class="modal-footer">
                    <button type="button" id="confirm_close" class="btn btn-default"
                            data-dismiss="modal" onclick="confirmCloseAssignment()">确认
                    </button>
                    <button type="button" id="cancel_close" class="btn btn-default"
                            data-dismiss="modal" onclick="cancelCloseAssignment()">取消
                    </button>
                </div>
            </div>
        </div>
    </div>
    <!--弹出操作提示消息-->
    <div class="modal fade" id="operationMessage" tabindex="-1" role="dialog"
         aria-labelledby="myModalLabel" style="top:40%">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header" style="background-color: #307095;font-weight: bold;">
                    <label>请填写不合格原因：</label>
                </div>

                <div id="msgBoxMsg" class="modal-body" style="overflow:auto;text-align:center;">

                 <input style="width:400px;height:100px;" type="text" id="fankui" name="fankuiyy" />

                </div>
                <div class="modal-footer" style="text-align:center;">
                    <button type="button"class="btn btn-default" onclick="confirmCloses()"
                            data-dismiss="modal">确认
                    </button>

                    <button type="button"class="btn btn-default"
                            data-dismiss="modal">取消
                    </button>
                </div>
            </div>
        </div>
    </div>

    <!--弹出没有选择用户的提示消息-->
    <div class="modal fade" id="userMessage" tabindex="-1" role="dialog"
         aria-labelledby="myModalLabel" style="top:40%">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div id="msgBoxMsg" class="modal-body" style="overflow:auto;text-align:center;">
                    请至少选择一个用户！
                </div>
                <div class="modal-footer" style="text-align:center;">
                    <button type="button"class="btn btn-default"
                            data-dismiss="modal">确认
                    </button>
                </div>
            </div>
        </div>
    </div>

    <!--弹出任务回收提示消息-->
    <div class="modal fade" id="retrieveMessage" tabindex="-1" role="dialog"
         aria-labelledby="myModalLabel" style="top:40%">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div id="msgBoxMsg" class="modal-body" style="overflow:auto;text-align:center;">
                    确定要回收吗?
                </div>
                <div class="modal-footer" style="text-align:center;">
                    <button type="button"class="btn btn-default" onclick="retrieve()"
                            data-dismiss="modal">确认
                    </button>
                    <button type="button"class="btn btn-default"
                            data-dismiss="modal">取消
                    </button>
                </div>
            </div>
        </div>
    </div>

    <!--弹出任务通过提示消息-->
    <div class="modal fade" id="adopt" tabindex="-1" role="dialog"
         aria-labelledby="myModalLabel" style="top:40%">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div id="msgBoxMsg" class="modal-body" style="overflow:auto;text-align:center;">
                    确定要通过吗?
                </div>
                <div class="modal-footer" style="text-align:center;">
                    <button type="button"class="btn btn-default" onclick="adopt()"
                            data-dismiss="modal">确认
                    </button>
                    <button type="button"class="btn btn-default"
                            data-dismiss="modal">取消
                    </button>
                </div>
            </div>
        </div>
    </div>

    <!--弹出任务合格提示消息-->
    <div class="modal fade" id="passMessage" tabindex="-1" role="dialog"
         aria-labelledby="myModalLabel" style="top:40%">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div id="msgBoxMsg" class="modal-body" style="overflow:auto;text-align:center;">
                    确定要判定为合格状态吗？
                </div>
                <div class="modal-footer" style="text-align:center;">
                    <button type="button"class="btn btn-default" onclick="pass()"
                            data-dismiss="modal">确认
                    </button>
                    <button type="button"class="btn btn-default"
                            data-dismiss="modal">取消
                    </button>
                </div>
            </div>
        </div>
    </div>

    <!--弹出任务不合格提示消息-->
    <div class="modal fade" id="rejectMessage" tabindex="-1" role="dialog"
         aria-labelledby="myModalLabel" style="top:40%">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div id="msgBoxMsg" class="modal-body" style="overflow:auto;text-align:center;">
                    确定要判定为不合格状态吗?
                </div>
                <div class="modal-footer" style="text-align:center;">
                    <button type="button"class="btn btn-default" onclick="reject()"
                            data-dismiss="modal">确认
                    </button>
                    <button type="button"class="btn btn-default"
                            data-dismiss="modal">取消
                    </button>
                </div>
            </div>
        </div>
    </div>

    <!--弹出任务不合格提示消息-->
    <div class="modal fade" id="rejectMessageall" tabindex="-1" role="dialog"
         aria-labelledby="myModalLabel" style="top:40%">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div id="msgBoxMsg" class="modal-body" style="overflow:auto;text-align:center;">
                    确定要将以合格任务全部判定为不合格状态吗?
                </div>
                <div class="modal-footer" style="text-align:center;">
                    <button type="button"class="btn btn-default" onclick="rejectall()"
                            data-dismiss="modal">确认
                    </button>
                    <button type="button"class="btn btn-default"
                            data-dismiss="modal">取消
                    </button>
                </div>
            </div>
        </div>
    </div>
    <!--弹出任务不合格提示消息-->
    <div class="modal fade" id="rejectMessageall1" tabindex="-1" role="dialog"
         aria-labelledby="myModalLabel" style="top:40%">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div id="msgBoxMsg" class="modal-body" style="overflow:auto;text-align:center;">
                    确定要将待审核任务全部判定为不合格状态吗?
                </div>
                <div class="modal-footer" style="text-align:center;">
                    <button type="button"class="btn btn-default" onclick="rejectall1()"
                            data-dismiss="modal">确认
                    </button>
                    <button type="button"class="btn btn-default"
                            data-dismiss="modal">取消
                    </button>
                </div>
            </div>
        </div>
    </div>
    <!--弹出任务修改为不合格提示消息-->
    <div class="modal fade" id="revokeMessage" tabindex="-1" role="dialog"
         aria-labelledby="myModalLabel" style="top:40%">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div id="msgBoxMsg" class="modal-body" style="overflow:auto;text-align:center;">
                    确定要修改为不合格状态吗?
                </div>
                <div class="modal-footer" style="text-align:center;">
                    <button type="button"class="btn btn-default" onclick="revoke()"
                            data-dismiss="modal">确认
                    </button>
                    <button type="button"class="btn btn-default"
                            data-dismiss="modal">取消
                    </button>
                </div>
            </div>
        </div>
    </div>

    <!--弹出任务修改为合格提示消息-->
    <div class="modal fade" id="checkMessage" tabindex="-1" role="dialog"
         aria-labelledby="myModalLabel" style="top:40%">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div id="msgBoxMsg" class="modal-body" style="overflow:auto;text-align:center;">
                    确定要修改为已合格状态吗?
                </div>
                <div class="modal-footer" style="text-align:center;">
                    <button type="button"class="btn btn-default" onclick="check()"
                            data-dismiss="modal">确认
                    </button>
                    <button type="button"class="btn btn-default"
                            data-dismiss="modal">取消
                    </button>
                </div>
            </div>
        </div>
    </div>

    <!--弹出代码的正则-->
    <div class="modal fade" id="GetRegexp" tabindex="-1" role="dialog"
         aria-labelledby="myModalLabel" style="top:40%">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div id="" class="modal-body" style="overflow:auto;text-align:center;">
                    <textarea name="regexp_value" id="regexp_value" style="margin: 0px; height: 257px; width: 566px;" disabled></textarea>
                </div>
                <div class="modal-footer" style="text-align:center;">
                    <button type="button"class="btn btn-default" data-dismiss="modal">确认</button>
                </div>
            </div>
        </div>
    </div>
    <!--弹出采集数量-->
    <div class="modal fade" id="GatherCount" tabindex="-1" role="dialog"
         aria-labelledby="myModalLabel" style="top:40%">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div id="" class="modal-body" style="overflow:auto;text-align:center;">
                    <p>采集数量: <input type="text" id="gather_count" disabled></p>
                    <textarea name="regexp_value" id="gather_urls" style="margin: 0px; height: 257px; width: 566px;" disabled></textarea>
                </div>
                <div class="modal-footer" style="text-align:center;">
                    <button type="button"class="btn btn-default" data-dismiss="modal">确认</button>
                </div>
            </div>
        </div>
    </div>
    <input id="taskIds" value="" style="display:none;"></input>
    </div>
    <script>

        function getUrlParam(name){
            var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
            var r = window.location.search.substr(1).match(reg);  //匹配目标参数
            if (r!=null) return unescape(r[2]); return null; //返回参数值
        }
        function allUnqualified(pid) {
           $('#rejectMessageall').modal()
        }
        function rejectall(){
            $.ajaxSetup({
                data:{
                    csrfmiddlewaretoken:'{{ csrf_token }}',
                    pid: '{{ pid }}',
                    condition:'qualified',
                }
            });
            $.post(
                "{% url 'task:reject' %}",
                function(response){
                    var msg = response.message;
                    if (msg){
                        alert(msg);
                    }
                    toPage("current");
                    clearCheckAll();
                }
            )
        }
        function allUnqualified1(pid) {
           $('#rejectMessageall1').modal()
        }
        function rejectall1(){
            $.ajaxSetup({
                data:{
                    csrfmiddlewaretoken:'{{ csrf_token }}',
                    pid: '{{ pid }}',
                    condition:'examine',
                }
            });
            $.post(
                "{% url 'task:reject' %}",
                function(response){
                    var msg = response.message;
                    if (msg){
                        alert(msg);
                    }
                    toPage("current");
                    clearCheckAll();
                }
            )
        }
        function __reject(tids){
            $.ajaxSetup({
                data:{
                    csrfmiddlewaretoken:'{{ csrf_token }}',
                    tids: tids
                }
            });
            $.post(
                "{% url 'task:reject' %}",
                function(response){
                    var msg = response.message;
                    if (msg){
                        alert(msg);
                    }
                    toPage("current");
                    clearCheckAll();
                }
            )
        }
        function rejectOneTask(tids){
            if (tids){
                tids = tids + "";
                $("#taskIds").val(tids);
                $("#rejectMessage").modal();
            }else{
                return false
            }
        }

        function operation(tids) {
            if (tids){
                tids = tids + "";
                $("#taskIds").val(tids);
                $("#operationMessage").modal();
            }else{
                return false
            }
        }

        function _reject(tids){
            if (!tids){
                var _tids = [];
                $("input[name='td_checkbox']:checked").each(
                    function(){
                        _tids.push($(this).val())
                    }
                );
                tids = _tids.join();
            }
            if (tids.length === 0){
                $("#taskMessage").modal();
                return false
            }else{
                $("#taskIds").val(tids);
                $("#rejectMessage").modal()
            }
        }
        function reject(tids){
            if (!tids){
                tids = $("#taskIds").val();
            }
            if (tids.length === 0){
                $("#taskMessage").modal();
                return false
            }else{
                __reject(tids)
            }
            $("#taskIds").val("")
        }

        function n_reject(tids,cvalue){
            var tid = tids;
            var cvalue = cvalue;
            $.ajaxSetup({
                data:{
                    csrfmiddlewaretoken:'{{ csrf_token }}',
                    tids: tids,
                    cvalue: cvalue,
                }
            });
            $.post(
                "{% url 'task:reject' %}",
                function(response){
                    var msg = response.message;
                    if (msg){
                        alert(msg);
                    }
                    toPage("current");
                    clearCheckAll();
                }
            )
        }

        function __pass(tids){
            $.ajaxSetup({
                data:{
                    csrfmiddlewaretoken:'{{ csrf_token }}',
                    tids: tids
                }
            });
            $.post(
                "{% url 'task:pass' %}",
                function(response){
                    var msg = response.message;
                    if (msg){
                        alert(msg);
                    }
                    toPage("current");
                    clearCheckAll();
                }
            )
        }
        function passOneTask(tids) {
            if (tids){
                tids = tids + "";
                $("#taskIds").val(tids);
                $("#passMessage").modal();
            }else{
                return false
            }
        }
        function _pass(tids){
            if (!tids){
                var _tids = [];
                $("input[name='td_checkbox']:checked").each(
                    function(){
                        _tids.push($(this).val())
                    }
                );
                tids = _tids.join();
            }
            if (tids.length === 0){
                $("#taskMessage").modal();
                return false
            }else{
                $("#taskIds").val(tids);
                $("#passMessage").modal()
            }
        }
        function pass(tids){
            if (!tids){
                tids = $("#taskIds").val()
            }
            if (tids.length === 0){
                $("#taskMessage").modal();
                return false
            }else{
                __pass(tids)
            }
            $("#taskIds").val("");
        }

        function __retrieve(tids){
            $.ajaxSetup({
                data:{
                    csrfmiddlewaretoken:'{{ csrf_token }}',
                    tids: tids,
                }
            });
            $.post(
                "{% url 'task:retrieve' %}",
                function(response){
                    var msg = response.message;
                    if (msg){
                        alert(msg);
                    }
                    toPage("current");
                    clearCheckAll();
                }
            )
        }
        function retrieveOneTask(tids){
            if (tids){
                tids = tids + "";
                $("#taskIds").val(tids);
                $("#retrieveMessage").modal();
            }else{
                return false
            }
        }
        function _retrieve(tids){
            if (!tids){
                var _tids = [];
                $("input[name='td_checkbox']:checked").each(
                    function(){
                        _tids.push($(this).val())
                    }
                );
                tids = _tids.join();
            }
            if (tids.length === 0){
                $("#taskMessage").modal();
                return false
            }else{
                $("#taskIds").val(tids);
                $("#retrieveMessage").modal()
            }
        }
        function retrieve(tids){
            if (!tids){
                tids = $("#taskIds").val();
            }
            if (tids.length === 0){
                $("#taskMessage").modal();
                return false
            }else{
                __retrieve(tids)
            }
            $("#taskIds").val("")
        }


        function adoptone(tids){
            if (tids){
                tids = tids + "";
                $("#taskIds").val(tids);
                $("#adopt").modal();
            }else{
                return false
            }
        }
        function _adopt(tids){
            if (!tids){
                var _tids = [];
                $("input[name='td_checkbox']:checked").each(
                    function(){
                        _tids.push($(this).val())
                    }
                );
                tids = _tids.join();
            }
            if (tids.length === 0){
                $("#taskMessage").modal();
                return false
            }else{
                $("#").val(tids);
                $("#adopt").modal()
            }
        }
        function adopt(tids){
            if (!tids){
                tids = $("#taskIds").val();
            }
            if (tids.length === 0){
                $("#taskMessage").modal();
                return false
            }else{
                __adopt(tids)
            }
            $("#taskIds").val("")
        }

        function __adopt(tids){
            $.ajaxSetup({
                data:{
                    csrfmiddlewaretoken:'{{ csrf_token }}',
                    tids: tids,
                }
            });
            $.post(
                "{% url 'task:adopt' %}",
                function(response){
                    var msg = response.message;
                    if (msg){
                        alert(msg);
                    }
                    toPage("current");
                    clearCheckAll();
                }
            )
        }

        function __revoke(tids){
            $.ajaxSetup({
                data:{
                    csrfmiddlewaretoken:'{{ csrf_token }}',
                    tids: tids
                }
            });
            $.post(
                "{% url 'task:revoke' %}",
                function(response){
                    var msg = response.message;
                    if (msg){
                        alert(msg);
                    }
                    toPage("current");
                    clearCheckAll();
                }
            )
        }
        function revokeOneTask(tids){
            if (tids){
                tids = tids + "";
                $("#taskIds").val(tids);
                $("#revokeMessage").modal();
            }else{
                return false
            }
        }
        function _revoke(tids){
            if (!tids){
                var _tids = [];
                $("input[name='td_checkbox']:checked").each(
                    function(){
                        _tids.push($(this).val())
                    }
                );
                tids = _tids.join();
            }
            if (tids.length === 0){
                $("#taskMessage").modal();
                return false
            }else{
                $("#taskIds").val(tids);
                $("#revokeMessage").modal()
            }
        }
        function revoke(tids){
            if (!tids){
                tids = $("#taskIds").val()
            }
            if (tids.length === 0){
                $("#taskMessage").modal();
                return false
            }else{
                __revoke(tids)
            }
            $("#taskIds").val("")
        }

        function __check(tids){
            $.ajaxSetup({
                data:{
                    csrfmiddlewaretoken:'{{ csrf_token }}',
                    tids: tids
                }
            });
            $.post(
                "{% url 'task:check' %}",
                function(response){
                    var msg = response.message;
                    if (msg){
                        alert(msg);
                    }
                    toPage("current");
                    clearCheckAll();
                }
            )
        }
        function checkOneTask(tids){
            if (tids){
                tids = tids + "";
                $("#taskIds").val(tids);
                $("#checkMessage").modal();
            }else{
                return false
            }
        }
        function _check(tids){
            if (!tids){
                var _tids = [];
                $("input[name='td_checkbox']:checked").each(
                    function(){
                        _tids.push($(this).val())
                    }
                );
                tids = _tids.join();
            }
            if (tids.length === 0){
                $("#taskMessage").modal();
                return false
            }else{
                $("#taskIds").val(tids);
                $("#checkMessage").modal()
            }
        }
        function check(tids){
            if (!tids){
                tids = $("#taskIds").val();
            }
            if (tids.length === 0){
                $("#taskMessage").modal();
                return false
            }else{
                __check(tids)
            }
            $("#taskIds").val("")
        }
        function _allocate(tids,agency_id){
            if (!tids){
                var _tids = [];
                $("input[name='td_checkbox']:checked").each(
                    function(){
                        _tids.push($(this).val())
                    }
                );
                tids = _tids.join();
            }
            if (tids.length === 0) {
                $("#taskMessage").modal();
                return false
            }
            else{
                $("#taskIds").val(tids);
                showUsers(tids,agency_id);
            }
        }
        function allocate(tids, uids){
            if (!tids){
                tids = $("#taskIds").val();
            }
            if (!uids){
                var _uids = [];
                $("input[name='utd_checkbox']:checked").each(
                    function(){
                        _uids.push($(this).val())
                    }
                );
                uids = _uids.join();
            }
            if(uids.length === 0){
                return false
            }
            if (tids.length === 0){
                console.log(tids,uids);
                $("#taskMessage").modal();
                return false
            }else{
                $.ajaxSetup({
                    data:{
                        csrfmiddlewaretoken:'{{ csrf_token }}',
                        tids: tids,
                        uids: uids
                    }
                });
                $.post(
                    "{% url 'task:allocate' %}",
                    function(response){
                        var msg = response.message;
                        console.log(msg);
                        if (msg){
                            alert(msg);
                        }
                        mainVue.message = response.message;
                        toPage('current');
                        clearCheckAll();
                    }
                )
            }
            $("#taskIds").val("");
        }




         function allocateOneTask(tids,agency_id){
            _allocate(tids,agency_id);

        }

        function Assignment(tids,agency_id) {
            $("#taskIds").val(tids);
                showUsers_Assignment(tids,agency_id);
        }
        function allocateAssignment(tids, uids){
            if (!tids){
                tids = $("#taskIds").val();
            }
            if (!uids){
                var _uids = [];
                $("input[name='utd_checkbox']:checked").each(
                    function(){
                        _uids.push($(this).val())
                    }
                );
                uids = _uids.join();
            }
            if(uids.length === 0){
                return false
            }
            if (tids.length === 0){
                console.log(tids,uids);
                $("#taskMessage").modal();
                return false
            }else{
                $.ajaxSetup({
                    data:{
                        csrfmiddlewaretoken:'{{ csrf_token }}',
                        tids: tids,
                        uids: uids
                    }
                });
                $.post(
                    "{% url 'task:allocate' %}",
                    function(response){
                        var msg = response.message;
                        console.log(msg);
                        if (msg){
                            alert(msg);
                        }
                        mainVue.message = response.message;
                        toPage('current');
                        clearCheckAll();
                    }
                )
            }
            $("#taskIds").val("");
        }

        function detailOneTask(tid){
            {% if model_DOM_id == 'manage' %}
           var url = "{% url 'task:detail' %}" + "?id=" + tid + "&type=task" + "&user=admin";
            {% else %}
            var url = "{% url 'task:detail' %}" + "?id=" + tid + "&type=task" + "&user=user";
            {% endif %}
           window.location.href = url;
        }

        function confirmClose(){
            var tids = $("#taskIds").val();
            var userIds = [];
            $("input[name='utd_checkbox']:checked").each(
                function(){
                    userIds.push($(this).val());
                }
            );
            if (tids.length === 0){
                $("#taskMessage").modal();
                return false;
            }
            uids = userIds.join();
            if (uids.length === 0){
                $("#userMessage").modal();
                return false
            }
            $("#aaa").html('');
            allocate(tids, uids);
            _clearChecked();
        }
        function cancelClose(){
            $("#aaa").html('');
            _clearChecked();
        }

        function confirmCloseAssignment(){
            $("#aaa").html('');
            var tids = $("#taskIds").val();
            var userIds = [];
            $("input[name='utd_checkbox']:checked").each(
                function(){
                    userIds.push($(this).val());
                }
            );
            if (tids.length === 0){
                $("#taskMessage").modal();
                return false;
            }
            uids = userIds.join();
            if (uids.length === 0){
                $("#userMessage").modal();
                return false
            }
            allocateAssignment(tids, uids);
            _clearChecked();
        }

        function cancelCloseAssignment(){
            $("#aaa").html('');
            _clearChecked();
        }

        function _clearChecked(){
            if ($("input[name='uth_checkbox']").is(":checked")){
                $("input[name='uth_checkbox']").prop("checked", false)
            }
            $("input[name='utd_checkbox']:checked").each(
                function(){
                    $(this).prop("checked", false);
                }
            );
        }
        function showUsers(tids,agency_id){
            console.log(agency_id)
            var aaa = $("#aaa");
            aaa.html('');
            {% for user in configUsers %}
                 if ('{{ user.user.agency_id }}' == agency_id){
                    aaa.append("<tr>\n" +
                        "                                    <td class=\"action-checkbox\">\n" +
                        "                                        <input type=\"radio\" name=\"utd_checkbox\" value=\"{{ user.user.id }}\" onclick=\"_checkOne(this)\">\n" +
                        "                                    </td>\n" +
                        "                                    <td>{{ user.user.username }}</td>\n" +
                        "                                </tr>");
            }

            {% endfor %}
            if(aaa.html() === ''){
                alert('未获到该组所属用户！')
            }else{
                var userBox = $("#userList");
                userBox.modal();
            }

        }

        function showUsers_Assignment(tids,agency_id){
            var bbb = $("#bbb");
            bbb.html('');
            {% for user in configUsers %}
                 if ('{{ user.user.agency_id }}' == agency_id ){
                    bbb.append("<tr>\n" +
                        "                                    <td class=\"action-checkbox\">\n" +
                        "                                        <input type=\"radio\" name=\"utd_checkbox\" value=\"{{ user.user.id }}\" onclick=\"_checkOne(this)\">\n" +
                        "                                    </td>\n" +
                        "                                    <td>{{ user.user.username }}</td>\n" +
                        "                                </tr>");
            }

            {% endfor %}
            if(bbb.html() === ''){
                alert('未获到该组所属用户！')
            }else{
                var userBox = $("#userListAssignment");
                userBox.modal();
            }

        }

        function confirmCloses(){
            var tids = $("#taskIds").val();
            var fankui = $("#fankui").val();
            var uid = {{ user_id|safe }};
            var cvalue = fankui + "#" + uid
            // alert(cvalue);
            if (tids.length === 0){
                $("#taskMessage").modal();
                return false;
            }
            if (cvalue === ''){
                $("#taskMessage").modal();
                return false
            }
            else {
                 n_reject(tids,cvalue)
            }

        }

        function checkAll(obj){
            if ($(obj).is(":checked")){
                $("input[name='td_checkbox']").prop("checked", true)
            }else{
                $("input[name='td_checkbox']").prop("checked", false)
            }

        }
            function clearCheckAll(){
                $("input[name='th_checkbox']").prop("checked", false)
            }
        function checkOne(obj){
            if ($("input[name='th_checkbox']").is(":checked")){
                $("input[name='th_checkbox']").prop("checked", false)
            }else{
                var unChecked = 0;
                $("input[name='td_checkbox']").each(
                    function(){
                        if ($(this).is(":checked")){

                        }else{
                            unChecked += 1
                        }
                    }
                );
                if (unChecked === 0){
                    $("input[name='th_checkbox']").prop("checked", true)
                }
            }
        }
        function _checkAll(obj){
            if ($(obj).is(":checked")){
                $("input[name='utd_checkbox']").prop("checked", true)
            }else{
                $("input[name='utd_checkbox']").prop("checked", false)
            }

        }
        function _checkOne(obj){
            if ($("input[name='uth_checkbox']").is(":checked")){
                $("input[name='uth_checkbox']").prop("checked", false)
            }else{
                var unChecked = 0;
                $("input[name='utd_checkbox']").each(
                    function(){
                        if ($(this).is(":checked")){

                        }else{
                            unChecked += 1
                        }
                    }
                );
                if (unChecked === 0){
                    $("input[name='uth_checkbox']").prop("checked", true)
                }
            }
        }

        function accept_project(pid){
            if (pid.length === 0){
                return false
            }else{
                $.ajaxSetup({
                    data:{
                        csrfmiddlewaretoken:'{{ csrf_token }}',
                        pid: pid
                    }
                });
                $.post(
                    "{% url 'task:accept_pjc' %}",
                    function(response){
                        alert(response.message);
                        mainVue.message = response.message;
                        toPage('current')
                    }
                )
            }
        }

        Vue.config.delimiters = ["[[", "]]"];


        function toPage(page){
            if (mainVue.paginator){
                if (page == 'current'){
                    page = mainVue.paginator.current
                }
                if (page == 'next'){
                    page = mainVue.paginator.current + 1
                }
                if (page == 'prev'){
                    page = mainVue.paginator.current - 1
                }
                if (page == 'first'){
                    page = 1
                }
                if (page == 'last'){
                    page = mainVue.paginator.last
                }
                if (page == 'judge'){
                    page = $("#page-judge").val();
                }
                if (page < 1) {
                    page = 1;
                }
                if (page > mainVue.paginator.last){
                    page = mainVue.paginator.last;
                }
                if (page < mainVue.paginator.first){
                    page = mainVue.paginator.first;
                }
            }else{
                page = 1;
            }
            mainVue.page = page;
            render(mainVue);
        }

        function render(obj){
            var searchForm = obj.searchForm + '&page=' + obj.page;
            $.get(
                "{% url 'task:show_project_detail' %}",
                searchForm,
                function(response){
                    if (response){
                        obj.showMain = true;
                        obj.tableData = response.tableData;
                        obj.paginator = response.paginator;
                        obj.message = response.message;

                        console.log(obj.tableData)
                    }else{
                        obj.showMain = false;
                    }
                }
            )
        }
        var mainVue = new Vue({
            el: "#main",
            data: {
                page: 1,
                status: 1,
                limit: {{ limit }},
                searchForm: "",
                checkedAll: false,
                showMain: false,
                tableData: {},
                auditRecord: {},
                paginator: {},
                message: ""
            },
            methods: {
                parseTime :function (timeStamp){
                    if (!timeStamp){
                        return ""
                    }
                    var newDate = new Date();
                    newDate.setTime(timeStamp * 1000);
                    return newDate.toLocaleDateString()
                },
                truncatechars: function(str, end){
                    if (!str){
                        return ""
                    }
                    if(end <= str.length){
                        return str.slice(0,end) + '...'
                    }else{
                        return str
                    }
                },
                parseStatus: function(status){
                    var statuses = {
                        1:{
                            name:"已回收"
                        },
                        2:{
                            name:"待分配"
                        },
                        3:{
                            name:"处理中"
                        },
                        4:{
                            name:"待审核"
                        },
                        5:{
                            name:"已合格"
                        },
                        6:{
                            name:"不合格"
                        },
                        9:{
                            name:"已结算"
                        },
                        10:{
                            name:"已反馈"
                        },
                        11:{
                            name:"任务回收申请"
                        },
                        12:{
                            name:"任务回收通过"
                        },
                        13:{
                            name:"任务回收驳回"
                        },
                         14:{
                            name:"已通过"
                        }

                    };
                    return statuses[status]["name"]
                },
                //searchTasks: searchTasks,
                getTasks: function(){
                    var searchForm = 'page=' + this.page + '&limit=' + this.limit + '&status=' + this.status;
                    $.get(
                        "{% url 'task:unallocated_tasks' %}",
                        searchForm,
                        function(response){
                            if (response){
                                this.showMain = true;
                                this.tableData = response.tableData;
                                this.paginator = response.paginator;
                                this.message = response.message;
                                console.log(this.paginator);
                            }else{
                                this.showMain = false;
                            }
                        }
                    )
                }
            },
            watch: {
{#                page: function(){#}
{#                    render(this);#}
{#                }#}
            }
        });

        function getUrlParam(name){
            var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
            var r = window.location.search.substr(1).match(reg);  //匹配目标参数
            if (r!=null) return unescape(r[2]); return null; //返回参数值
        }

        function searchTasks(){
            var pid = getUrlParam("pid");
            var status = getUrlParam("status");
            if(status!=null){
                mainVue.searchForm = "pid=" + pid + "&limit=20&uid={{ uid }}&status=" + status;
            }else{
                mainVue.searchForm = "pid=" + pid + "&limit=20&uid={{ uid }}";
            }
            $.get(
                "{% url 'task:show_project_detail' %}",
                mainVue.searchForm,
                function(response){
                    if (response){
                        mainVue.limit = response.limit;
                        mainVue.showMain = true;
                        mainVue.limits = response.limits;
                        mainVue.tableData = response.tableData;
                        mainVue.paginator = response.paginator;
                        mainVue.message = response.message;
                    }else{
                        mainVue.showMain = false;
                    }
                }
            )
        }
        searchTasks();
        function changeColor(id, color){
            //$(id).parent().parent().parent().children().children().children().find("li[color='green']");
            $(id).parent().parent().addClass("active");
            $(id).children().css("color", color);
        }
        //$("#taskManager").addClass("active");
         if('{{ is_agent }}'==='1'){
            changeColor("#{{ model_DOM_id }}_project_agent", "#00FF7F");
        }else {
            changeColor("#{{ model_DOM_id }}_project", "#00FF7F");
        }

        // 获取正则
        function getRegexp(tid) {
            $('#regexp_value').val('');
            $.post({
                url: "{% url 'task:get_regexp' %}",
                data: {
                    tid: tid,
                    csrfmiddlewaretoken:'{{ csrf_token }}'
                },
                success: function (resp) {
                    $('#regexp_value').val(resp.regexps);
                    // console.log(resp)
                },
                error: function (resp) {
                    alert('查看失败')
                }
            });
            $("#GetRegexp").modal();
        }
        // 采集数量
        function getGatherCount(tid) {
            $('#gather_count').val('');
            $.post({
                url: "{% url 'task:get_gather_count' %}",
                data: {
                    tid: tid,
                    csrfmiddlewaretoken:'{{ csrf_token }}'
                },
                success: function (resp) {
                    $('#gather_count').val(resp.count);
                    $('#gather_urls').val(resp.urlstr)
                    // console.log(resp)
                },
                error: function (resp) {
                    alert('查看失败')
                }
            });
            $("#GatherCount").modal();
        }

        // 审核记录
        function auditRecord(tids) {
            mainVue.auditRecord = {};
            if (tids){
                var searchForm = 'tid='+tids;
                $.get(
                    "{% url 'task:task_audit_record_detail' %}",
                    searchForm,
                    function(response) {
                        if(response){
                            console.log(response.data);
                            mainVue.auditRecord = response.data;
                        }
                    });
                $("#taskIds").val(tids);
                $("#auditRecord").modal();
            }else{
                return false
            }
        }
    </script>
{% endblock section_content %}
